<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .container {
        margin: 100px auto;
        width: 400px;
        height: 400px;
        border: 5px solid red;
      }
      .box {
        /*width: 198px;
            height: 200px;
            float: left;  边框线也占用宽度
            border: 1px solid black;*/
        width: 200px;
        height: 200px;
        margin: 100px auto;
        border: 5px solid black;
        padding: 20px;
        word-wrap: break-word;
        /*内容的实际宽度为200px （包含文本宽度150px+边框10px+内边距40px）*/
        box-sizing: border-box;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;

        /*盒子的实际宽度为242px （包含文本宽度200px+边框2px+内边距40px）默认值 */
        /*box-sizing: content-box;
        -moz-box-sizing: content-box;
        -webkit-box-sizing: content-box;*/
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="box">
        border-box：设定的宽高决定了元素的边框盒，元素的内边距和边框都在已设定的宽度和高度内绘制，内容的宽高为设定的宽高减去内边距和边框。(即设定的宽高包括内边距，边框和内容区)
      </div>
    </div>
  </body>
</html>
